package com.ymatou.iapi.trading.operate2.resp;

import com.ymatou.iapi.trading.operate2.parameter.vo.ErrorCode;

public class BaseResponse {
	private static final long serialVersionUID = -5719901720924490738L;

	private boolean success;

	private ErrorCode errorCode;

	private String errorMessage;

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	public ErrorCode getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(ErrorCode errorCode) {
		this.errorCode = errorCode;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public BaseResponse(boolean success) {
		this.success = success;
	}

	public BaseResponse() {
	}

	public static BaseResponse newSuccessInstance() {
		BaseResponse result = new BaseResponse();
		result.setSuccess(true);
		return result;
	}

	public static BaseResponse newFailInstance(ErrorCode errorCode) {
		BaseResponse result = new BaseResponse();
		result.setSuccess(false);
		result.setErrorCode(errorCode);
		result.setErrorMessage(errorCode == null ? "" : errorCode.getMessage());
		return result;
	}
}
